using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using linkouqs.Gamekit;

public class Demo : MonoBehaviour {
    [SerializeField]
    GameObject gameobject1 = null;
    [SerializeField]
    GameObject gameobject2 = null;
    [SerializeField]
    float Distance = 0f;
    [SerializeField]
    float Force = 0f;
    private void Update() {
        if (Input.GetKeyDown(KeyCode.Space))
            if ((gameobject1.transform.position - gameobject2.transform.position).magnitude < Distance) {
                Vector3 x = gameobject1.transform.position, y = gameobject2.transform.position;
                gameobject1.GetComponent<CharacterController2D>().Move((x - y).normalized * Force);
                gameobject2.GetComponent<CharacterController2D>().Move((x - y).normalized * -Force);

            }
    }
}


